package com.hairline.controller;

import com.hairline.bean.Comment;
import com.hairline.bean.vo.BaseRespVo;
import com.hairline.bean.vo.CommentListVO;
import com.hairline.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class CommentController {

    @Autowired
    CommentService commentService;

    @RequestMapping("/admin/comment/list")
    public BaseRespVo list(Integer page, Integer limit, String sort, String order, Integer userId, Integer valueId) {

        CommentListVO commentListVO = commentService.selectCommentsVO(page, limit, sort, order, userId, valueId);

        return BaseRespVo.ok(commentListVO);
    }

    @RequestMapping("/admin/comment/delete")
    public BaseRespVo delete(@RequestBody Comment comment) {
        boolean flat = commentService.deleteById(comment);
        if (flat) {
            return BaseRespVo.ok();
        }
        return BaseRespVo.fail();
    }
}
